/*
 * @作者: kerwin
 * @公众号: 大前端私房菜
 */
var express = require("express");
const NewsController = require("../../controllers/admin/NewsController");
var NewsRouter = express.Router();

const multer = require("multer");
const upload = multer({ dest: "public/newsuploads/" });

//涉及文件上传, 普通post不行, 需要加上 multer中间件
NewsRouter.post(
  "/adminapi/news/add",
  upload.single("file"),
  NewsController.add
);
//获取新闻列表
NewsRouter.get("/adminapi/news/list", NewsController.getList);
//发布新闻
NewsRouter.put("/adminapi/news/publish", NewsController.publish);
//删除新闻
NewsRouter.delete("/adminapi/news/list/:id", NewsController.delList);
//编辑新闻 查找
NewsRouter.get("/adminapi/news/list/:id", NewsController.getList);
//编辑新闻 提交
NewsRouter.post(
  "/adminapi/news/list",
  upload.single("file"),
  NewsController.updateList
);

module.exports = NewsRouter;
